Skip to content

Premium Analytics: converge the duplicated date-label validators and day bounds - #52070

Open
chihsuan wants to merge 3 commits into
trunkfrom
change/wooa7s-2079-dedup
Open

Premium Analytics: converge the duplicated date-label validators and day bounds#52070
chihsuan wants to merge 3 commits into
trunkfrom
change/wooa7s-2079-dedup

Conversation

@chihsuan

@chihsuan chihsuan commented Sep 8, 2026

Copy link
Copy Markdown
Member

Fixes WOOA7S-2079 (items 3, 4, 7 and part of 5; item 1 is #52064)

Proposed changes

  • Extract one parseExactLabel( label, labelFormat ) into packages/datetime and route the five copies of the parse + isValid + round-trip format idiom through it, along with the two copies of its new Date( 2001, 0, 1 ) reference date.
  • Delete toValidDay in use-post-views.ts, which duplicated the shared toDay character for character. Its sibling widget already imported the shared one.
  • Name the '00:00:00' / '23:59:59' day bounds as DAY_START_TIME / DAY_END_TIME in stats/utils.ts, next to the three files that use them.

No behavior changes, so nothing in readme.txt and no plugin changelog entries. The only test file edited gains assertions; none was moved or weakened.

Related product discussion/links

Does this pull request change what data or activity we track or use?

No.

Testing instructions

Nothing to click. This is an internal refactor with no user-visible surface, so the check is that the existing suites still pass without any assertion being edited.

  • jp test js packages/premium-analytics (or, scoped: PA_TEST_GROUPS=1 TZ=UTC npx jest --config=tests/jest.config.cjs packages/datetime packages/data widgets/post-views widgets/popular-days packages/widgets-toolkit), 166 suites, 1531 tests.
  • pnpm run typecheck and pnpm run lint-changed.
  • Reviewing the diff, the thing worth checking is that each rewritten call site is equivalent, in particular the Date | null to undefined conversion in readRowDate and the reference-date consolidation.

@chihsuan chihsuan self-assigned this Sep 8, 2026
@chihsuan chihsuan changed the title WOOA7S-2079: Premium Analytics: converge the duplicated date-label validators and day bounds Premium Analytics: converge the duplicated date-label validators and day bounds Sep 8, 2026
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack or WordPress.com Site Helper), and enable the change/wooa7s-2079-dedup branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack change/wooa7s-2079-dedup
bin/jetpack-downloader test jetpack-mu-wpcom-plugin change/wooa7s-2079-dedup

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!

@jp-launch-control

Copy link
Copy Markdown

Code Coverage Summary

Coverage changed in 6 files. Only the first 5 are listed here.

File Coverage Δ% Δ Uncovered
projects/packages/premium-analytics/packages/data/src/processing/stats/post.ts 24/24 (100.00%) 0.00% 0 💚
projects/packages/premium-analytics/packages/data/src/processing/stats/time-series.ts 100/105 (95.24%) -0.04% 0 💚
projects/packages/premium-analytics/packages/data/src/processing/stats/utils.ts 102/104 (98.08%) 0.04% 0 💚
projects/packages/premium-analytics/packages/datetime/src/date.ts 23/23 (100.00%) 0.00% 0 💚
projects/packages/premium-analytics/widgets/popular-days/bucket-views-by-weekday.ts 18/18 (100.00%) 4.55% -1 💚

Full summary · PHP report · JS report

@chihsuan
chihsuan force-pushed the change/wooa7s-2079-dedup branch from 09210d3 to 9bb650f Compare September 9, 2026 04:05
@chihsuan
chihsuan marked this pull request as ready for review September 9, 2026 06:03
@chihsuan
chihsuan requested a review from a team as a code owner September 9, 2026 06:03
@chihsuan chihsuan added [Status] Needs Review This PR is ready for review. and removed [Status] In Progress labels Sep 9, 2026

@layoutd layoutd left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Followed the testing instructions: full premium-analytics suite, typecheck and lint-changed all green on the branch. Also went through each rewritten call site against the original: toValidDay was identical to the shared toDay, and the null vs undefined swap in readRowDate is absorbed by its one caller (if ( ! date )). Clicked through Popular days and Post views on a local site too and nothing moved.

Significance: patch
Type: changed

Report dates: read every round-trip-validated date label and day bound through one helper.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This reads as implementation detail. Since the PR says no behavior changes, the changelog guideline in AGENTS.md points at an empty entry with a -c comment. Not blocking

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants